import {
  IsArray,
  IsEmail,
  IsOptional,
  IsString,
  Length,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateUserDto {
  @ApiProperty({ example: '1482983333@qq.com', description: '用户名(邮箱)' })
  @IsString()
  @IsEmail()
  username: string;

  @ApiProperty({ example: '123abc456', description: '密码(6-16位)' })
  @IsString()
  @Length(6, 16)
  password: string;

  @ApiProperty({
    example: ['user', 'admin'],
    description: '角色暂定(user、admin)',
    required: false,
  })
  @IsArray()
  @IsOptional()
  roles?: string[];

  @ApiProperty({
    example: '102135',
    description: '6位数组验证码',
  })
  @IsString()
  @Length(6)
  captcha: string; //验证码
}
